186B - Growing Mushrooms - CodeForces Solution


greedy sortings *1200

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
// #include <boost/algorithm/string.hpp>
 
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define sz(a) (ll)a.size()
#define py cout<<"YES\n";
#define pn cout<<"NO\n";
const int MOD = 1000000007;
#define forn(i, n) for (int i = 0; i < int(n); i++)


const double PI = acos(-1);
// #define size 102

const int MXX = 1001;
bitset<MXX + 1> isPrime;
vector<int> primes;

// long matrix[size][size];

// int a[size][size],b[size][size];
void sieve() {
    // false = prime, true = not prime
    isPrime[0] = isPrime[1] = true;
    for (int i = 4; i <= MXX; i += 2) isPrime[i] = true;
 
    for (int i = 3; 1LL * i * i <= MXX; i += 2) {
        if (!isPrime[i]) {
            for (int64_t j = i * i; j <= MXX; j += i + i) isPrime[j] = true;
        }
    }
    for (int i = 0; i < MXX; ++i) {
        if (!isPrime[i])
            primes.push_back(i);
    }
}
struct comp{
    bool operator()(pair<int,int>&a,pair<int,int>&b){
        return a.first+a.second<b.first+b.second;
    }
};
    
bool cmp(pair<string,ll>&a, pair<string,ll>&b){
    if(a.first.size()==b.first.size())
        return a<b;
    return a.first.size()>b.first.size();
}

ll smallestPrime(ll n){
    for(ll i=2;i*i<=n;i++){
        if(n%i==0)
            return i;
    }
    return n;
}

bool isPal(int n){
    
    int x=0,i=n;
    while(n){
        x=(x*10+n%10);
        n/=10;
    }
    
    if(x!=i)    return false;
    return true;
}


ll rec(ll i, ll sum, vector<ll>&pal, vector<vector<ll>>&dp){
    
    if(sum==0)  return 1;
    
    if(i<0 || sum<0)    return 0;
    
    if(i==0 && sum==pal[i])     return 1;
    
    if(dp[i][sum]!=-1)  return dp[i][sum];
    
    ll take=0,leave=0;
    take =rec(i,sum-pal[i],pal,dp);
    leave=rec(i-1,sum,pal,dp);
  
    return dp[i][sum]=(take%MOD+leave%MOD)%MOD;
}
vector<ll>mirror={0,1,5,-1,-1,2,-1,-1,8,-1};

ll fact(ll n){
    if (n == 0 || n == 1)
        return 1;
    return n * fact(n - 1);
}

ll cnt(vector<ll>v){
    ll ans=0,zero=0,n=v.size();
    
    for(ll i=n-1;i>=0;i--){
        if(v[i]==0)
            zero++;
        else    ans+=zero;
        // cout<<zero<<endl;
    }
    // cout<<ans<<"fgh"<<endl;
    return ans;
}

void solve(){
    
    // ll n;    cin>>n;
   
    // string s;    cin>>s;
    // char ch;    cin>>ch;
    
    // vector<ll>v(n);
    // forn(i,n)    cin>>v[i];
    
    ll n,t1,t2,k;   cin>>n>>t1>>t2>>k;
    vector<pair<double,ll>>vp;
  
    forn(i,n){
        ll a,b; cin>>a>>b;
        
        double val=0;
        
        val=max((double)a*t1*(100-k)/100+b*t2,(double)b*t1*(100-k)/100+a*t2);
        val*=-1;
        
        vp.pb({val,i+1});
    }
  
    sort(vp.begin(),vp.end());
    
    for(auto [x,y]:vp)
        cout<<y<<" "<<-1*x<<endl;
   
   
    // cout<<"-------------"<<endl;
    
    return;
} 

int main()
{
    // clock_t time_req = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed << setprecision(2);
    ll t=1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    
    // time_req = clock() - time_req;
    // cout << (float)time_req / CLOCKS_PER_SEC;
    return 0;
}


Comments

Submit
0 Comments
More Questions

158A - Next Round
71A - Way Too Long Words
160A - Twins
1A - Theatre Square
1614B - Divan and a New Project
791A - Bear and Big Brother
1452A - Robot Program
344A - Magnets
96A - Football
702B - Powers of Two
1036A - Function Height
443A - Anton and Letters
1478B - Nezzar and Lucky Number
228A - Is your horseshoe on the other hoof
122A - Lucky Division
1611C - Polycarp Recovers the Permutation
432A - Choosing Teams
758A - Holiday Of Equality
1650C - Weight of the System of Nested Segments
1097A - Gennady and a Card Game
248A - Cupboards
1641A - Great Sequence
1537A - Arithmetic Array
1370A - Maximum GCD
149A - Business trip
34A - Reconnaissance 2
59A - Word
462B - Appleman and Card Game
1560C - Infinity Table
1605C - Dominant Character